package 初级算法;

public class 移动零 {

    public static void main(String[] args) {
        int[] is =new int[]{0,1,0,3,12};
        moveZeroes(is);
        for (int i : is) {
            System.out.println(i);
        }
    }
    public static void moveZeroes(int[] nums) {
        int left = 0;
        for (int right = 0; right < nums.length; right++) {
            if(nums[right]!=0){
                nums[left++] =nums[right];
            }
        }
        for (int i = left; i < nums.length; i++) {
            nums[i]=0;
        }
    }
}
